﻿namespace SimpleWebServices.Web.Mvc
{
    using System;
    using System.Net;
    using System.Web;
    using System.Web.Mvc;
    using Moq;
    using Xunit;

    public sealed class NotAcceptableResultFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<NotAcceptableResult>()
                .DerivesFrom<ActionResult>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new NotAcceptableResult());
        }

        [Fact]
        public void op_ExecuteResult_ControllerContextNull()
        {
            Assert.Throws<ArgumentNullException>(() => new NotAcceptableResult().ExecuteResult(null as ControllerContext));
        }

        [Fact]
        public void op_ExecuteResult_ControllerContext()
        {
            var mock = new Mock<HttpContextBase>();
            mock.SetupSet(x => x.Response.StatusCode).Callback(expected => Assert.Equal<int>((int)HttpStatusCode.NotAcceptable, expected)).Verifiable();
            mock.Setup(x => x.Response.Cache.SetCacheability(HttpCacheability.NoCache)).Verifiable();

            new NotAcceptableResult().ExecuteResult(new ControllerContext()
            {
                HttpContext = mock.Object
            });

            mock.VerifyAll();
        }
    }
}